# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=juicy-potato
pkgver=53.744d321
pkgrel=1
pkgdesc='A sugared version of RottenPotatoNG, with a bit of juice.'
groups=('blackarch' 'blackarch-windows')
arch=('any')
url='https://github.com/ohpe/juicy-potato'
license=('GPL3')
makedepends=('git')
source=("git+https://github.com/ohpe/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  jobId=$(curl https://ci.appveyor.com/api/projects/ohpe/juicy-potato | sed 's|.*jobId":"\([^"]*\)".*|\1|gi')
  baseUrl="https://ci.appveyor.com/api/buildjobs/${jobId}/artifacts/"

  curl -L -o './juicypotato.exe' "${baseUrl}JuicyPotato%2FRelease%2Fx64%2FJuicyPotato.exe"

  install -dm 755 "$pkgdir/usr/share/windows/$pkgname"

  cp -a ./CLSID "$pkgdir/usr/share/windows/$pkgname/"
  cp -a ./Test "$pkgdir/usr/share/windows/$pkgname/"
  install -Dm 644 ./juicypotato.exe "$pkgdir/usr/share/windows/$pkgname/"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

